package course;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import course.method;
import java.io.PrintWriter;
/**
 * Servlet implementation class update
 */
@WebServlet("/update")
public class update extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public update() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
		request.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		String id = request.getParameter("id");
		String uname =request.getParameter("uname");
		String age =request.getParameter("age");
		String school =request.getParameter("school");
		out.print(school);
		String sex =request.getParameter("sex");
		String phone =request.getParameter("phone");
		String province =request.getParameter("province");
		String city =request.getParameter("city");
		String area =request.getParameter("area");
		method.Connection("UPDATE studentinfo SET uname="+'"'+uname+'"'+",age="+'"'+age+'"'+",school="+'"'+school+'"'+",sex="+'"'+sex+'"'+",phone="+'"'+phone+'"'+",hometown="+'"'+province+city+area+'"'+" WHERE idnum="+'"'+id+'"'); 
		 response.sendRedirect("index.jsp");   
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
